﻿namespace TestSim
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Headers;
    using System.Text;
    using System.Threading.Tasks;

    class Program
    {
        static List<Store> foodstores = new List<Store>();

        static void Main(string[] args)
        {
            #region comment out
            // Reference
            //http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client
            //using (var client = new HttpClient())
            //{
            //    client.BaseAddress = new Uri("http://localhost:9000/");
            //    client.DefaultRequestHeaders.Accept.Clear();
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            //    // New code:
            //    //HttpResponseMessage response = await client.GetAsync("http://dev.etracks.web/api/Store");
            //    //if (response.IsSuccessStatusCode)
            //    //{
            //    //    Product product = await response.Content.ReadAsAsync>Product>();

            //    //    Console.WriteLine("{0}\t${1}\t{2}", product.Name, product.Price, product.Category);
            //    //}
            //}

            //string[] names = new string[] {
            //    "Robert",
            //    "Jennifer",
            //    "Edna",
            //    "Thomas",
            //    "Martha", 
            //    "Charles"
            //};
            #endregion comment out

            List<Player> players = new List<Player>();
            players.Add(new Player("Robert", 20, 500));
            players.Add(new Player("Jennifer", 100, 1000));
            players.Add(new Player("Edna", 100, 1300));


            int cycle = 0;
            Console.WriteLine("[START]");
            while (players.Exists(p => p.Energy > 0))
            {
                Console.WriteLine("Cycle: {0}", cycle++);
                
                foreach (Player p in players.Where(p => p.Energy > 0).ToList())
                {
                    Console.WriteLine("{0} has {1} energy left.", p.Name, p.Energy);
                }

                System.Threading.Thread.Sleep(5000);

                Console.WriteLine("----------------------------------------");
            }
            Console.WriteLine("[END]");
        }
    }
}


